%this function introduces matrix transformations in a cell array of
%matrices.


% Enter data transformation if necessary. Use matrix format.
% For instance, the following is a matrix of transformations (Trns):

%                     X  Y  U1  U2  U3  ...  Un
% Inversion/scale   [-1  1  -1   1   1  ...   1 ]
% Horizontal flip   [ 1  0   1   0   0  ...   0 ]
% Vertical flip     [ 0  1   0   0   0  ...   0 ]
% Transpose         [ 0  1   0   0   0  ...   0 ]
% 
% Enter only the cells to modify.
% E.g. Trns(1,1)=-1; Trns(1,4)=-1; Trns(2,1)=1;
%       Trns(2,4)=1; Trns(3,2)=1; Trns(4,2)=1


%Created by Ricardo Mejia-Alvarez.
%University of Illinois at Urbana-Champaign.
%Urbana, IL. 06/16/2010

function [A] = Transformation(Trns , A)

for k = 1 : length(A)
    A(k) = { A{k} * Trns(1 , k) };
    
    if Trns(2 , k) == 1
        A(k) = { fliplr(A{k}) };
    end
    
    if Trns(3 , k) == 1
        A(k) = { flipud(A{k}) };
    end
    
    if Trns(4 , k) == 1
        A(k) = { (A{k})' };
    end
    
end





end

